load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "poseidon",
    hdrs = ["poseidon.h"],
    deps = [
        ":poseidon_config",
        ":poseidon_sponge_base",
        "//tachyon/base/buffer:copyable",
        "//tachyon/crypto/hashes/sponge:sponge_state",
        "//tachyon/math/matrix:matrix_operations",
    ],
)

tachyon_cc_library(
    name = "poseidon_config",
    hdrs = ["poseidon_config.h"],
    deps = [
        ":poseidon_config_base",
        ":poseidon_config_entry",
        ":sparse_mds_matrix",
        "//tachyon/base:optional",
        "//tachyon/base/buffer:copyable",
        "//tachyon/base/ranges:algorithm",
        "//tachyon/math/finite_fields:finite_field_traits",
        "@com_google_absl//absl/types:span",
    ],
)

tachyon_cc_library(
    name = "poseidon_config_base",
    hdrs = ["poseidon_config_base.h"],
    deps = [
        "//tachyon/base/buffer:copyable",
        "//tachyon/math/finite_fields:finite_field_traits",
        "//tachyon/math/matrix:matrix_types",
    ],
)

tachyon_cc_library(
    name = "poseidon_config_entry",
    hdrs = ["poseidon_config_entry.h"],
    deps = [":poseidon_config_entry_base"],
)

tachyon_cc_library(
    name = "poseidon_config_entry_base",
    hdrs = ["poseidon_config_entry_base.h"],
    deps = [
        ":poseidon_grain_lfsr",
        "//tachyon/math/finite_fields:finite_field_traits",
    ],
)

tachyon_cc_library(
    name = "poseidon_grain_lfsr",
    hdrs = ["poseidon_grain_lfsr.h"],
    deps = [
        "//tachyon/math/base:big_int",
        "//tachyon/math/finite_fields:finite_field_traits",
        "//tachyon/math/matrix:matrix_types",
    ],
)

tachyon_cc_library(
    name = "poseidon_params",
    hdrs = ["poseidon_params.h"],
    deps = ["//tachyon/math/finite_fields/baby_bear/internal:baby_bear"],
)

tachyon_cc_library(
    name = "poseidon_sponge_base",
    hdrs = ["poseidon_sponge_base.h"],
    deps = [
        "//tachyon/base:logging",
        "//tachyon/crypto/hashes:prime_field_serializable",
        "//tachyon/crypto/hashes/sponge",
        "@eigen_archive//:eigen3",
    ],
)

tachyon_cc_library(
    name = "sparse_mds_matrix",
    hdrs = ["sparse_mds_matrix.h"],
    deps = [
        "//tachyon/base:logging",
        "//tachyon/base/buffer:copyable",
        "//tachyon/base/strings:string_util",
        "//tachyon/math/matrix:matrix_types",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_unittest(
    name = "poseidon_unittests",
    srcs = [
        "poseidon_config_unittest.cc",
        "poseidon_grain_lfsr_unittest.cc",
        "poseidon_unittest.cc",
        "sparse_mds_matrix_unittest.cc",
    ],
    deps = [
        ":poseidon",
        ":poseidon_config",
        ":poseidon_params",
        ":sparse_mds_matrix",
        "//tachyon/base/buffer:vector_buffer",
        "//tachyon/math/elliptic_curves/bls12/bls12_381:fr",
        "//tachyon/math/elliptic_curves/bn/bn254:fr",
        "//tachyon/math/finite_fields/baby_bear",
        "//tachyon/math/finite_fields/test:finite_field_test",
    ],
)
